<?php

class _F_EXTENSION_DATA_ extends _F_EXTENSION_ {
	
	public function __construct() {
		$dir = dirname(__FILE__);
		require_once $dir.'/connection.php';
		require_once $dir.'/select.php';
		require_once $dir.'/query.php';
		require_once $dir.'/result_set.php';
		require_once $dir.'/model.php';
		f()->register_method('data',array($this,'data'));
	}
	
	public function data() {
		return $this;
	}
	
	public function connect($name,$options) {
		new _F_EXTENSION_DATA_CONNECTION_($name,$options);
	}
	
	public static function _f_error_info_($connection,$query,$stmnt = null) {
		$info = $stmnt === null ? $connection->errorInfo() : $stmnt->errorInfo();
		$code = $info[0];
		if (!empty($info[1])) $code .= ':'.$info[1];
		$msg = $info[2];
		error_log("Database error: [$code] ($msg) in query \"$query\"");
		if ($stmnt != null) $stmnt->debugDumpParams();
	}
	
}

new _F_EXTENSION_DATA_();
